load("//dotnet:defs.bzl", "csharp_library", "dotnet_nunit_test_suite", "nuget_package")

filegroup(
    name = "assembly-fixtures",
    testonly = True,
    srcs = [
        "AssemblyFixture.cs",
    ],
    visibility = [
        "//dotnet/test:__subpackages__",
    ],
)

filegroup(
    name = "test-data",
    testonly = True,
    srcs = [],
    data = [
        "appconfig.json",
        "//common/extensions",
        "//common/src/web",
        "//dotnet/src/webdriver:manager-linux",
        "//dotnet/src/webdriver:manager-macos",
        "//dotnet/src/webdriver:manager-windows",
        "//java/test/org/openqa/selenium/environment:appserver",
        "//java/test/org/openqa/selenium/environment:keystore",
        "//javascript/atoms",
        "//third_party/closure/goog",
        "//third_party/js/selenium:webdriver_json",
    ],
    visibility = [
        "//dotnet/test:__subpackages__",
    ],
)

csharp_library(
    name = "fixtures",
    testonly = True,
    srcs = glob(
        ["**/*.cs"],
        exclude = [
            "**/*Test.cs",
            "**/*Tests.cs",
        ],
    ),
    data = [
        "//common/manager:selenium-manager-macos",
    ],
    target_frameworks = ["net8.0"],
    visibility = [
        "//dotnet/test:__subpackages__",
    ],
    deps = [
        "//dotnet/src/webdriver:webdriver-net8.0",
        nuget_package("NUnit"),
        nuget_package("Runfiles"),
    ],
)

# copy_file(
#     name = "manager-macos",
#     src = "//common/manager:selenium-manager-macos",
#     out = "manager/macos/selenium-manager",
# )

dotnet_nunit_test_suite(
    name = "AllTests",
    size = "small",
    srcs = glob([
        "**/*Test.cs",
        "**/*Tests.cs",
    ]) + [
        ":assembly-fixtures",
    ],
    out = "WebDriver.Common.Tests",
    browsers = [
        # The first browser in this list is assumed to be the one that should
        # be used by default.
        "firefox",
        # "safari",  # Skipping safari for now
        "ie",
        "edge",
        "chrome",
    ],
    data = [
        ":test-data",
    ],
    target_frameworks = ["net8.0"],
    deps = [
        ":fixtures",
        "//dotnet/src/webdriver:webdriver-net8.0",
        nuget_package("BenderProxy"),
        nuget_package("NUnit"),
        nuget_package("Runfiles"),
    ],
)
